﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using SvnCore;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for Outer.xaml
    /// </summary>
    public partial class Outer : UserControl
    {
        public Outer()
        {
            InitializeComponent();
        }

        public void DoSomething()
        {
            Inner inner = new Inner();
            CanvasInOuter.Children.Add(inner);
            GetControlPosition(inner);
            Point transform = button1.TransformToAncestor(Application.Current.MainWindow).Transform(new Point(0, 0));
        }

        Point GetControlPosition(UIElement myControl)
        {

            Point locationToScreen = myControl.PointToScreen(new Point(0, 0));
            PresentationSource source = PresentationSource.FromVisual(myControl);

            return source.CompositionTarget.TransformFromDevice.Transform(locationToScreen);
        }
    }
}
